from rest_framework import serializers

from user.models import RiderProfile, ShopProfile, CustomerProfile


class CustomerProfileSerializer(serializers.ModelSerializer):
    customer_add = serializers.CharField(max_length=64, required=False)
    nickname = serializers.CharField(max_length=32, required=False)

    class Meta:
        model = CustomerProfile
        fields = ('customer_add', 'nickname')


class ShopProfileSerializer(serializers.ModelSerializer):
    shop_name = serializers.CharField(max_length=64, required=False)
    shop_add = serializers.CharField(max_length=64, required=False)

    class Meta:
        model = ShopProfile
        fields = ('shop_name', 'shop_add', 'info')


class RiderProfileSerializer(serializers.ModelSerializer):
    rider_name = serializers.CharField(max_length=32, required=False)

    # 构造类序列器时只传入data则save调用create方法,传入instance和data则调用update方法
    class Meta:
        model = RiderProfile
        fields = ('rider_name', )

